package com.ts.animal.service.impl;

import com.ts.animal.dao.RfidLabelDao;
import com.ts.animal.domain.RfidLabelDO;
import com.ts.animal.service.RfidLabelService;
import com.ts.common.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class RfidLabelServiceImpl implements RfidLabelService {
    @Autowired
    private RfidLabelDao rfidLabelDao;

    @Override
    public RfidLabelDO get(String num) {
        return rfidLabelDao.get(num);
    }

    @Override
    public List<RfidLabelDO> list(Map<String, Object> map) {
        return rfidLabelDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return rfidLabelDao.count(map);
    }

    @Override
    public int save(Result result, RfidLabelDO rfidLabel) {
        int ret = rfidLabelDao.save(rfidLabel);
        if (ret == 0) {
            result.set(Result.FAIL, "保存失败", null);
        }
        return ret;


    }

    @Override
    public int update(Result result, RfidLabelDO rfidLabel) {
        int ret = rfidLabelDao.update(rfidLabel);
        if (ret == 0) {
            result.set(Result.FAIL, "更新失败", null);
        }
        return ret;
    }

    @Override
    public int remove(Result result, String num) {
        int ret = rfidLabelDao.remove(num);
        if (ret == 0) {
            result.set(Result.FAIL, "删除失败", null);
        }
        return ret;
    }

    @Override
    public int batchRemove(Result result, String[] nums) {
        int ret = rfidLabelDao.batchRemove(nums);
        if (ret != nums.length) {
            result.set(Result.FAIL, "部分删除失败", null);
        }
        return ret;
    }

}
